<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>国省自检--${fns:getConfig('productName')}</title>
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<script type="text/javascript">
function btnClick(){
	var url = '${ctx}/trafficSurvey/search.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}';
	var data = {};
	if($('#btnSearch').length>0){ //有搜索按钮的情况下 获取条件进行搜索
		//将条件提取出来 
		//将条件存入data中
		//ajax请求   得到数据
		data['retrieval'] = getJson('condition');
		loadData(url,data);
	} else {
		loadData(url,data);
	}
}
//ajax执行成功之后的回调方法
function loadDataToTable(data){
	var attment = data['att'];
	var overView = data['overView'];
	var timeReslut = data['timeResult'];
	if($('#stationName').length>0){
		$('#station tbody').empty();
		for (var j = 0; j < overView.length; j++) {
			var tr = "<tr><td>"+parseInt(j+1)+"</td><td>"+overView[j].stationName+"</td><td>"+overView[j].year+"</td>"+
					 "<td>"+Pengtu.buildCodeName(1000,overView[j].stationPlan)+"</td><td>"+Pengtu.buildCodeName(1000,overView[j].stationConstruction)+"</td>"+
					 "<td>"+Pengtu.buildCodeName(1000,overView[j].stationAnalyze)+"</td><td>"+Pengtu.buildCodeName(1000,overView[j].yearReport)+"</td>"+
					 "<td>"+Pengtu.buildCodeName(1000,overView[j].normalRun)+"</td><td>"+Pengtu.buildCodeName(1000,overView[j].dataComplete)+"</td><td>";
			if(overView[j].bulletinNumber > 0){
				tr += imgRight;
			} else {
				tr += imgError;
			}
			tr +="</td><td>"+overView[j].remark+"</td></tr>";
			$('#station tbody').append(tr);
		}
	}
	loadAttachment(attment);
	
	
	//返回评分结果
	if(data['years'] != undefined){
		//每次搜索前清空表格
		$('#checkResult').empty();
		var years = data['years'];
		var yearDate = "";
		var detailDate ="";
		var result="";
		var attDate = "";
		var checkDate = "";
		var checkStation ="";
		var anDate = "";
		var tempNormalRun = "";
		var tempDataComplete = "";
		
		var w= 0;
		for (var j = 0; j < timeReslut.length; j++) {
			if (timeReslut[j] == 0){
				checkDate += '<td></td><td></td>';
				result += '<td colspan="2"></td>';
			} else if (timeReslut[j] == 1) {
				for(;w < overView.length;){
					if (overView[w].yearReport == 1){
						checkDate += '<td>√</td>';
					} else {
						checkDate += '<td>×</td>';
					}
					
					if (overView[w].stationAnalyze == 1){
						checkDate += '<td>√</td>';
					} else {
						checkDate += '<td>×</td>';
					}
					result += '<td colspan="2">'+overView[w].yearMark+'</td>';
					w++;
					break;
				}
			}
		}
		
		//默认取最后一年的情况做判断
		//文件得分
		if (overView[overView.length-1].stationConstruction == 1){
			anDate = '<td rowspan='+attment.length+'>是</td>';
		} else {
			anDate = '<td rowspan='+attment.length+'>否</td>';
		}
		anDate += '<td rowspan='+attment.length+'>'+overView[overView.length-1].attMark+'分</td>';
		
		//系统是否正常和数据是否完整
		if (overView[overView.length-1].normalRun == 1) {
			tempNormalRun = '<td>是</td>';
		} else {
			tempNormalRun = '<td>否</td>';
		}
		if (overView[overView.length-1].dataComplete == 1) {
			tempDataComplete = '<td>是</td>';
		} else {
			tempDataComplete = '<td>否</td>';
		}
		checkStation = '<tr><td>'+overView[overView.length-1].stationName+'</td>'+tempNormalRun+tempDataComplete+
					   '<td>'+overView[overView.length-1].runMark+'分</td>'+
					   '<td class="sumTd">'+data['sum']+'</td><td class="perTd" >'+data['percent']+'%</td></tr>';
		
		for (var i = 0; i < attment.length; i++) {
			if (i == 0) {
				attDate += "<tr><td rowspan='"+attment.length+"'>深圳市</td><td>"+attment[i].fileName+"</td><td>"+attment[i].fileTime+"</td>"+anDate+"</tr>";
			} else {
				attDate += "<tr><td>"+attment[i].fileName+"</td><td>"+attment[i].fileTime+"</td></tr>";
			}
		}
		
		for (var j = 0; j < years.length; j++) {
			yearDate += '<th colspan="2">'+years[j]+'</th>';
			detailDate += '<td>报告</td><td>运行分析</td>';
		}
		var content = '<table style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
					  '<th>省(市、区)</th><th>规划名称</th><th>出台时间</th><th>是否按计划完成</th><th>得分</th></tr>'+
					  '</thead><tbody>'+attDate+'</tbody></table>';			  
		$('#checkResult').append(content);
		
		var temp =	'<tr><td>检查结果</td>'+checkDate+'</tr><tr><td>检查得分</td>'+result+'</tr>';
		var yearReport = '<table style="width:98%;text-align:center;margin-top:10px;" border="1"><thead><tr>'+
						 '<th rowspan="2">年度报告</th>'+yearDate+'</tr><tr>'+detailDate+'</tr>'+
						 '</thead><tbody>'+temp+'</tbody></table>';
		$('#checkResult').append(yearReport);
		
		var runReport = '<table style="width:98%;text-align:center;margin-top:10px;" border="1"><thead><tr>'+
						'<th>交调站点名称</th><th>运行正常(是/否)</th><th>信息完整(是/否)</th><th>得分</th><th>检查总得分</th><th>完善度</th></tr>'+
						'</thead><tbody>'+checkStation+'</tbody></table>';
		
		$('#checkResult').append(runReport);
	}
	
	
}
</script>
</head>
<body>
	<div id="x_top"></div>
	<tags:message content="${msg}" />
	<c:if test="${not empty checkTable.id}">
		<div style="text-align:center">
			<a href="javascript:void(0);" class="btn btn-primary" onclick="downWord('${ctx}/trafficSurvey/downWord.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}');" id= "btnDown" role="button" ><div id="x_v"></div></a>
		</div>
	</c:if>
	<form id="checkForm" class="form-horizontal"  method="POST"  name="checkForm" action="${ctx}/trafficSurvey/save.do?left=${fns:encodeParam(left)}&parentId=${fns:encodeParam(parentId)}&projectId=${fns:encodeParam(projectId)}&menuId=${fns:encodeParam(menuId)}&leftChild=${fns:encodeParam(leftChild)}">
		<input type="hidden" name="token" value="${token}">
		<div id="show">
			<div id="showTable" class="showTable">
				<jsp:include page="/WEB-INF/views/check/common.jsp"/> 
				<div class="model">
					<div>
						<legend>三、检查条件及设置</legend>
						<div class="content-title" id="condition">
							<div style="margin-right:10px;">
								<span>站点名称:</span>
								<select name="stationName" id="stationName">
									<option value="">请选择</option>
									<c:forEach items="${fns:getTrafficAdjustByStationName()}" var="trafficAdjust"  varStatus="idxStatus">
										<option value="${trafficAdjust.stationName}">${trafficAdjust.stationName}</option>
									</c:forEach>
								</select>
							</div>
							<div style="float:left;margin-right:10px;margin-top:5px;">
								<span>制定站点布局规划并完成站点建设得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "yearFull" id="yearFull" value="1" class="required conInput"/>
								<span>只制定站点布局规划得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "yearPart" id="yearPart" value="0.5" class="required conInput"/>
							</div>
							<div style="float:left;margin-right:10px;margin-top:5px;">
								<span>开展交通量运行分析并编制年度报告得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "poitMark" id="poitMark" value="0.25" class="required conInput"/>
								<span>交调站点正常运行并数据完整得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "reserveMark" id="reserveMark" value="1" class="required conInput"/>
								<span>交调站点正常运行得分<font style="color:red;">*</font>：</span>
								<input type='text' name = "firstStepScore" id="firstStepScore" value="0.5" class="required conInput"/>
							</div>
							<div id="x_s" style="float:right">
								<div class="x_ico"></div>
								<a href="#javascript:void(0)" onclick= "btnClick();"  id= "btnSearch" role="button" >搜索&nbsp;</a>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>四、检索结果</legend>
						<div class="content-title">
							<div class="tabbox">
								<div class="tab">
									<a href="javascript:;" class="on">交调站点检查记录</a>
									<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
										<a href="javascript:;">${menu.name}</a>
									</c:forEach>
							    </div>
							    <div class="content">
							    	<ul>
							    		<li>
							    			<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="station">
							    				<thead>
							    					<th>序号</th>
										    		<th>站点名称</th>
										    		<th>年份</th>
										    		<th>是否有站点规划</th>
										    		<th>站点是否建设完成</th>
										    		<th>是否分析交调量分析</th>
										    		<th>是否编制年度报告</th>
										    		<th>站点是否正常运行</th>
										    		<th>数据是否完整</th>
										    		<th>已上相关文件</th>
										    		<th>备注</th>
									    		</thead>
								    			<tbody>
									    						
									    		</tbody>
							    			</table>
							    		</li>
							    		<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
							    			<c:if test="${idxStatus.index >= 0}">
							    				<li>
							    					<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
									    				<thead>
									    					<th>序号</th>
										    				<th>操作</th>
										    				<th>发文单位</th>
										    				<th>上传用户</th>
										    				<th>文件名</th>
										    				<th>发文日期</th>
										    				<th>上传日期</th>
										    				<th>文件大小</th>
										    				<th>文件类型</th>
										    			</thead>
								    					<tbody>
									    						
									    				</tbody>
							    					</table>
							    				</li>
							        		</c:if>
							    		</c:forEach>
							        </ul>
							    </div>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>五、检查评分</legend>
						<div class="content-title" id="checkResult">
						
						</div>
					</div>
				</div>
				<div class="model">
					<div class="content-btn">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="btnCancel" class="btn" type="button" value="返 回" onclick="toBack()" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<script src="${ctxStatic}/js/check/checkCommon.js" type="text/javascript"></script>
</body>
</html>